<?php 
/**
 * @version        $Id$
 * @author         master@xuewl.com
 * @copyright      Copyright (c) 2007 - 2014, Chongqing xuewl Information Technology Co., Ltd.
 * @link           http://www.xuewl.com
**/
class Wap
{
	public function system_init() {
		if (isset($_GET['ismobile']) == false) {
			cookie('ismobile', null);
			return FALSE;
		}
		$setting = getcache('setting', 'wap');
		if ($setting['wap_enable'] == 1 && $setting['wap_domain']) {
			$http_host = $_SERVER['HTTP_HOST'];
			$wap_domain = ltrim($setting['wap_domain'], "'http://'");
			$detect = new \Wap\Library\Mobile_Detect();
			if ($detect->isMobile() || stripos($http_host, $wap_domain) !== FALSE || cookie('ismobile') == 1) {
				cookie('ismobile', 1, 86400);
				define('DEFAULT_THEME', 'wap');
			}
		}
		return TRUE;
	}
}